package xyz.naokeziteng.leetcode;

import org.apache.commons.lang3.ArrayUtils;

import java.util.Arrays;

/**
 * @author hawk
 * @date 2022/6/6
 * @desc 455题：分发饼干
 **/
public class FindContentChildren {

    public int findContentChildren(int[] g, int[] s) {
        //先排序
        Arrays.sort(g);
        Arrays.sort(s);

        int result = 0;
        int j = 0;
        for (int i = 0; i < g.length; i++) {
            while (j < s.length && s[j] < g[i]) {
                j++;
            }
            if (j == s.length) {
                break;
            }
            result++;
            j++;
        }

        return result;
    }

    public static void main(String[] args) {
    }
}
